<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/12/6
 * Time: 16:28
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\timing\controller;

use app\BaseController;
use app\common\business\PlaceOrder;
use app\common\lib\Show;
use app\common\lib\Status;
use think\Exception;

class Order extends BaseController
{
    /**
     * 删除订单
     * @return \think\response\Json
     */
    public function abandoned()
    {
        //处理十分钟没有支付的订单
        $time = time() - 600;
        try {
            $order = (new PlaceOrder())->abandoned($time);
        } catch (\Exception $e) {
            return Show::json_show(Status::status_error, $e->getMessage());
        }
        return Show::json_show(Status::status_normal, "ok");
    }

    /**
     * 自动失效
     * @return \think\response\Json
     */
    public function invalid(){
        $time = time();
        try {
            $order = (new PlaceOrder())->invalid($time);
        } catch (\Exception $e) {
            return Show::json_show(Status::status_error, $e->getMessage());
        }
        return Show::json_show(Status::status_normal, "ok");
    }
}